Skip to content

fix(ui): 修复“真实加载/菜单总耗时”长期显示 0ms 的问题#14

Merged
adminLAla merged 2 commits intoHaerbin23456:devfrom
adminLAla:dev
Mar 15, 2026
Merged

fix(ui): 修复“真实加载/菜单总耗时”长期显示 0ms 的问题#14
adminLAla merged 2 commits intoHaerbin23456:devfrom
adminLAla:dev

Conversation

@adminLAla
Copy link
Collaborator

关联 Issue

变更摘要

1.修复真实加载统计来源,将“真实加载”改为基于当前扫描结果动态计算
2.改善扫描过程中的真实加载状态显示,系统扫描与文件扫描开始时都设置为“测量中”,避免旧值误导。
3.系统扫描结束后强制刷新统计,确保在进度回调为空或边界情况下,汇总指标仍可被刷新。
4.防止占位接口再次误导 UI,将占位接口返回值从 0 改为 -1,避免误被当作有效耗时。

主要改动

  • 优先使用每项的 WallClockTime
  • 若无 WallClockTime,则回退使用 TotalTime
  • 仅统计已启用扩展
  • 无有效测量值时显示 N/A

验证

  • [√] 本地构建通过
  • [√] 关键场景手测通过
  • [√] 未新增警告或已说明

截图/日志(如适用)

  • image

风险与兼容性

  • 风险较低:仅修改统计展示逻辑与占位返回值,不影响 Hook 通信协议
  • 兼容性:不涉及数据结构破坏性变更

Copilot AI review requested due to automatic review settings March 15, 2026 14:43
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

本 PR 旨在修复 Dashboard 中“真实加载/菜单总耗时”长期显示为 0ms(或被占位值误导)的问题,通过改为基于扫描结果动态汇总计算,并在扫描流程中更稳定地刷新统计。

Changes:

  • 扫描开始时将“真实加载”状态设为“测量中”,并在系统扫描结束后强制刷新汇总统计
  • 移除文件扫描后触发的 Real Benchmark 跑分逻辑,改由 UpdateStats() 基于 WallClockTime/TotalTime 动态计算真实加载
  • 将占位 RunRealShellBenchmark 返回值从 0 调整为 -1,避免 UI 将其当作有效耗时

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
ContextMenuProfiler.UI/ViewModels/DashboardViewModel.cs 扫描流程中刷新“真实加载”状态与汇总逻辑,真实加载改为按结果动态计算
ContextMenuProfiler.UI/Core/BenchmarkService.cs 调整占位 Real Benchmark API 的返回值,避免 0ms 误导展示

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 472 to 482
if (results.Count > 0)
{
// Use InsertSorted logic for consistency and performance
foreach (var res in results.OrderByDescending(r => r.TotalTime))
{
InsertSorted(res);
}
UpdateStats();
StatusText = string.Format(LocalizationService.Instance["Dashboard.Status.ScanComplete"], results.Count);
NotificationService.Instance.ShowSuccess(LocalizationService.Instance["Dashboard.Notify.ScanComplete.Title"], string.Format(LocalizationService.Instance["Dashboard.Notify.ScanCompleteForFile.Message"], results.Count, System.IO.Path.GetFileName(filePath)));
}
Comment on lines +707 to +711
// "Real load" uses wall-clock IPC time when available; fall back to measured COM stage total.
long realLoadMs = Results
.Where(r => r.IsEnabled)
.Sum(r => r.WallClockTime > 0 ? r.WallClockTime : Math.Max(0, r.TotalTime));
RealLoadTime = realLoadMs > 0 ? $"{realLoadMs} ms" : "N/A";
@@ -491,7 +491,7 @@ public List<BenchmarkResult> RunBenchmark(string targetPath)
return RunSystemBenchmark(ScanMode.Targeted); // Simplified for now
}

@adminLAla adminLAla merged commit 5baa63d into Haerbin23456:dev Mar 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants